
//--------------------------------------------------------------------//
//     此代码由T4模板自动生成										  //
//	   生成时间 2020-03-25 14:23:20 	                              //
//	   描述：Base_AnnexesFile
//--------------------------------------------------------------------//

using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Linq;
using Dapper;
using Newtonsoft.Json.Linq;
using RayD.Core;
using RayD.Repository;
using RayD.Repository.Entites.SystemModule;

namespace RayD.App.SystemModule
{
    public class AnnexesFileApp
    {
        #region 构造函数注入
        private IRepository BaseRepository;
        public AnnexesFileApp(IRepository repository)
        {
            this.BaseRepository = repository;
        }
        #endregion

        #region 获取数据
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns></returns>
        [Caching]
        public virtual AnnexesFileEntity GetEntity(string id)
        {
            return BaseRepository.FindEntity<AnnexesFileEntity>(c => c.B_Id == id);
        }
        /// <summary>
        /// 获取列表数据
        /// </summary>
        /// <param name="folderId">文件夹Id</param>
        /// <returns></returns>
        [Caching]
        public virtual List<AnnexesFileEntity> GetListByFolderId(string folderId)
        {
            var expression = LinqExtensions.True<AnnexesFileEntity>();
            return BaseRepository
                .IQueryable(expression.And(c => c.B_FolderId == folderId))
                .OrderBy(c => c.B_CreateDate)
                .ToList();
        }
        #endregion

        #region 提交数据
        /// <summary>
        /// 批量新增实体数据
        /// <summary>
        /// <param name="formEntities">数据实体集</param>
        /// <returns></returns>
        [RemoveCache]
        public virtual (bool, string) SaveForm(List<AnnexesFileEntity> formEntities)
        {
            BaseRepository.Insert(formEntities);
            return (true, "保存成功！");
        }
        /// <summary>
        /// 新增实体数据
        /// <summary>
        /// <param name="formEntity">数据实体</param>
        /// <returns></returns>
        [RemoveCache]
        public virtual (bool, string) SaveForm(AnnexesFileEntity formEntity)
        {
            //新增
            formEntity.Create();
            this.BaseRepository.Insert(formEntity);
            return (true, "保存成功！");
        }
        /// <summary>
        /// 删除实体数据
        /// <summary>
        /// <param name="formEntity">数据实体</param>
        /// <returns></returns>
        [RemoveCache]
        public virtual (bool, string) DeleteForm(AnnexesFileEntity formEntity)
        {
            this.BaseRepository.Delete(formEntity);
            return (true, "删除成功！");
        }
        #endregion

    }
}

